package HomeWork;

import java.util.ArrayList;

public class Test3 {
    public static void main(String[] args) {
        ArrayList<Worker> list=new ArrayList<>();
        list.add(new Worker("张三","3000"));
        list.add(new Worker("李四","3500"));
        list.add(new Worker("王五","4000"));
        list.add(new Worker("赵六","4500"));
        list.add(new Worker("田七","5000"));
        if (findName("王五",list)==-1){
            System.out.println("查无此人");
        }
        else {
            list.get(findName("王五",list)).setName("王小五");
        }
        if (findName("赵六",list)==-1){
            System.out.println("查无此人");
        }
        else {
            list.remove(findName("赵六",list));
        }
        if (findName("田七",list)==-1){
            System.out.println("查无此人");
        }
        else {
            list.get(findName("田七",list)).setSalary(Integer.parseInt(list.get(findName("田七",list)).getSalary())+500+"");
        }
        for (int i = 0; i < list.size(); i++) {
            System.out.println("姓名："+list.get(i).getName()+",  工资："+list.get(i).getSalary());
        }
    }
    public static int findName(String name,ArrayList<Worker> list){
        for (int i = 0; i < list.size(); i++) {
            if (list.get(i).getName().equals(name)){
                return i;
            }
        }
        return -1;
    }
}
